<template>
  <view class="container">
    <view class="role-select-container">
      <text class="title">欢迎</text>
      <!-- <text class="subtitle">请选择您的角色以继续：</text> -->
      
      <view class="role-buttons">
        <view class="role-btn" v-if="userRole.level == 1" @click="go('/pages/integration/intergrationMark/regimentalManage/regimentalManage')">
          <view class="icon blue">
            <uni-icons type="person" size="40" color="#FFFFFF"></uni-icons>
          </view>
          <text class="role-name" >您的角色：团长</text>
        </view>
        
        <!-- 组长 -->
        <view class="role-btn"  v-if="userRole.level == 2" @click="go('/pages/integration/intergrationMark/groupManage/groupManage')">
          <view class="icon green">
            <uni-icons type="contact" size="40" color="#FFFFFF"></uni-icons>
          </view>
          <text class="role-name">您的角色：组长</text>
        </view>
        
        <!-- 组员 -->
        <view class="role-btn" v-if="userRole.level == 3" @click="go('/pages/integration/intergrationMark/userManage/userManage')">
          <view class="icon purple">
            <uni-icons type="person" size="40" color="#FFFFFF"></uni-icons>
          </view>
          <text class="role-name">您的角色：组员</text>
        </view>
		
	
      </view>
	  <view  v-if="userRole==null">
	   您未分配身份
	  </view>
    </view>
  </view>
</template>

<script setup>
import { http } from '../../../utils/requestUtil';
import { ref, onMounted,computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app';
const userRole = ref()
const go =(url)=>{
	uni.navigateTo({
		url:url+"?orgId="+userRole.value.orgId
	})
	 // uni.navigateTo({ url });
}
const loadData =async()=>{
	console.log('1')
	const res =await http.get("/integral/organization/user")
	if(res.data == null){
		userRole.value=null
		return
	}
	userRole.value = res.data
	console.log(JSON.stringify(userRole.value))
}
onLoad(async () => {
  loadData()
});

</script>

<style scoped>
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f5f5f5;
  padding: 20rpx;
}

.role-select-container {
  background-color: #ffffff;
  border-radius: 16rpx;
  padding: 60rpx 40rpx;
  width: 100%;
  max-width: 600rpx;
  box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.1);
  text-align: center;
}

.title {
  font-size: 48rpx;
  font-weight: bold;
  color: #333333;
  margin-bottom: 20rpx;
  display: block;
}

.subtitle {
  font-size: 28rpx;
  color: #666666;
  margin-bottom: 60rpx;
  display: block;
}

.role-buttons {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 30rpx;
}

.role-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 180rpx;
  cursor: pointer;
}

.icon {
  width: 120rpx;
  height: 120rpx;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20rpx;
}

.blue {
  background-color: #4285f4;
}

.green {
  background-color: #34a853;
}

.purple {
  background-color: #9c27b0;
}

.role-name {
  font-size: 32rpx;
  color: #333333;
  font-weight: 500;
}
</style>